package com.example.demo.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.demo.dto.Jkpaperorder.JkpaperorderQueryRequest;
import com.example.demo.entity.Jkpaperorder;
import com.example.demo.service.JkpaperorderService;
import com.example.demo.dao.JkpaperorderMapper;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
* @author darling
* @description 针对表【jkpaperorder】的数据库操作Service实现
*/
@Service
public class JkpaperorderServiceImpl extends ServiceImpl<JkpaperorderMapper, Jkpaperorder>
    implements JkpaperorderService{

    @Override
    public QueryWrapper<Jkpaperorder> getQueryWrapper(JkpaperorderQueryRequest jkpaperorderQueryRequest) {
        QueryWrapper<Jkpaperorder> queryWrapper = new QueryWrapper<>();
        if (jkpaperorderQueryRequest == null) {
            return queryWrapper;
        }
        Integer id = jkpaperorderQueryRequest.getId();
        String number = jkpaperorderQueryRequest.getNumber();
        String outTradeNo = jkpaperorderQueryRequest.getOutTradeNo();
        Integer jkpaperid = jkpaperorderQueryRequest.getJkpaperid();
        Integer userid = jkpaperorderQueryRequest.getUserid();
        String username = jkpaperorderQueryRequest.getUsername();
        String jkpapername = jkpaperorderQueryRequest.getJkpapername();
        Integer price = jkpaperorderQueryRequest.getPrice();
        Date createtime = jkpaperorderQueryRequest.getCreatetime();
        Integer type = jkpaperorderQueryRequest.getType();
        Object state = jkpaperorderQueryRequest.getState();
        String sortField = jkpaperorderQueryRequest.getSortField();
        String sortOrder = jkpaperorderQueryRequest.getSortOrder();
        // 精确查询
        queryWrapper.eq(ObjectUtils.isNotEmpty(id), "id", id);
        queryWrapper.eq(ObjectUtils.isNotEmpty(number), "number", number);
        queryWrapper.eq(ObjectUtils.isNotEmpty(outTradeNo), "outTradeNo", outTradeNo);
        queryWrapper.eq(ObjectUtils.isNotEmpty(jkpaperid), "jkpaperid", jkpaperid);
        queryWrapper.eq(ObjectUtils.isNotEmpty(userid), "userid", userid);
        queryWrapper.eq(ObjectUtils.isNotEmpty(price), "price", price);
        queryWrapper.eq(ObjectUtils.isNotEmpty(createtime), "createtime", createtime);
        queryWrapper.eq(ObjectUtils.isNotEmpty(type), "type", type);
        queryWrapper.eq(ObjectUtils.isNotEmpty(state), "state", state);
        //模糊查询
        queryWrapper.like(ObjectUtils.isNotEmpty(username), "username", username);
        queryWrapper.like(ObjectUtils.isNotEmpty(jkpapername), "jkpapername", jkpapername);
        //排序规则
        queryWrapper.orderBy(ObjectUtils.isNotEmpty(sortField), sortOrder.equals("ascend"), sortField);
        return queryWrapper;
    }
}




